﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace _04.CountNumberInArrayTest
{
    [TestClass]
    public class CountNumberInArrayTest
    {
        [TestMethod]
        public void TestMethodZero()
        {
            int[] array = { 1, 2, 3, -4, -5, 0, 9999, -5, 0 };
            int result = CountNumberInArray.CountItem(0, array);
            Assert.AreEqual(2, result);
        }

        [TestMethod]
        public void TestMethodEmptyArray()
        {
            int[] array = { };
            int result = CountNumberInArray.CountItem(0, array);
            Assert.AreEqual(0, result);
        }

        [TestMethod]
        public void TestMethodOneNumberArray()
        {
            int[] array = { 99999 };
            int result = CountNumberInArray.CountItem(99999, array);
            Assert.AreEqual(1, result);
        }

        [TestMethod]
        public void TestMethodNegativeNumber()
        {
            int[] array = { 46, -45, 45 - 46, 0, int.MaxValue, int.MinValue, -666, -669, 666, 0 };
            int result = CountNumberInArray.CountItem(-666, array);
            Assert.AreEqual(1, result);
        }

        [TestMethod]
        public void TestMethodBorderNumber()
        {
            int[] array = { 46, -45, 45 - 46, 0, int.MaxValue, int.MinValue, -666, -669, int.MaxValue, int.MaxValue };
            int result = CountNumberInArray.CountItem(int.MaxValue, array);
            Assert.AreEqual(3, result);
        }

        [TestMethod]
        public void TestMethodArrayWithEqualNumbers()
        {
            int[] array = { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 };
            int result = CountNumberInArray.CountItem(5, array);
            Assert.AreEqual(10, result);
        }

        [TestMethod]
        public void TestMethodArrayWithDifferentTypes()
        {
            object[] array = { "1", "-1", "0", 1, -1, 0, 1, "1" };
            int result = CountNumberInArray.CountItem(1, array);
            Assert.AreEqual(2, result);
        }
    }
}
